<!DOCTYPE HTML>
<html>
	<head>
		<meta charset="utf-8"/>
		<meta name="viewport" content="initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
		<meta name="HandheldFriendly" content="true"/>
		<meta name="MobileOptimized" content="320"/>
		<title>Hello H5+</title>
		<script type="text/javascript" src="../../js/common.js"></script>
		<script src="../../js/getURLParam.js"></script>
		<link rel="stylesheet" href="../../css/mui.min.css">
	
		<script src="../../js/mui.min.js"></script>
		
		<script type="text/javascript">
var ws=null,wo=null;
var em=null,map=null;
// H5 plus事件处理
function plusReady(){
	if(!em||ws){return};
	// 获取窗口对象
	ws=plus.webview.currentWebview();
	wo=ws.opener();
	setTimeout(function(){
		map=new plus.maps.Map("map");
		map.centerAndZoom(new plus.maps.Point(116.3977,39.906016),5);
		//var sessionid="1";
	        var proVersion = "1.0";
	        var accountid="216";
	        var vclId="154719";
	        var keySta = "1";
	        var vclNum="";
			var keySta="";
			var lng ="";
			var lat ="";
			var posTime ="";
			var vclSpd ="";
			var vclDrct="";
			
		//getautoMap();
		//createMarker();
		// 创建子窗口
		//createSubview();
	},300);
	// 显示页面并关闭等待框
    ws.show("pop-in");
}
if(window.plus){
	plusReady();
}else{
	document.addEventListener("plusready",plusReady,false);
}
// DOMContentloaded事件处理
document.addEventListener("DOMContentLoaded",function(){
	em=document.getElementById("map");
	window.plus&&plusReady();
},false);
function userLocation(){
	map.showUserLocation( true );
	map.getUserLocation(function(state,pos){
		if(0==state){
			map.setCenter(pos);
		}
	});
}
function createMarker(){
	var marker=new plus.maps.Marker(new plus.maps.Point(116.347292,39.968716));
	marker.setIcon("../../images/drawable-hdpi/arrow_red.png");
	marker.setLabel("test");
	var bubble = new plus.maps.Bubble("打造最好的HTML5移动开发工具");
	marker.setBubble(bubble);
	map.addOverlay(marker);
}
function createSubview(){
	if('Android'!=plus.os.name){
		return;
	}
	// 创建加载内容窗口
	var topoffset='44px';
	if(plus.navigator.isImmersedStatusbar()){// 兼容immersed状态栏模式
		topoffset=(Math.round(plus.navigator.getStatusbarHeight())+44)+'px';
	}
	var wsub=plus.webview.create('maps_map_sub.html','sub',{top:topoffset,height:'60px',position:'absolute',scrollIndicator:'none',background:'transparent'});
	ws.append(wsub);
}
function resetMap(){
	map.centerAndZoom(new plus.maps.Point(116.3977,39.906016),12);
}
			mui.init({
				swipeBack: true //启用右滑关闭功能
				
			});
			//var sessionid=GetQueryString("sessionid");
	        //var proVersion = GetQueryString("proVersion");
	        //var accountid=GetQueryString("accountId");
	        //var vclId=GetQueryString("vclId");
	        //var keySta = GetQueryString("keySta");
	        var sessionid="1";
	        var proVersion = "1.0";
	        var accountid="216";
	        var vclId="154719";
	        var keySta ="1";
	        var vclNum="";
			var lng ="";
			var lat ="";
			var posTime ="";
			var vclSpd ="";
			var vclDrct="";
	         getautoMap();
			function getautoMap(){
				mui.ajax('http://222.223.231.137:8008/IEMS_APP_IOSG/APP/vclMapList',{          
				data:{param:'{"proVersion":"'+proVersion+'","accountId":"'+accountid+'","sessionid":"'+sessionid+'","data":{"vclId":"'+vclId+'","keySta":"'+"1"+'"}}'},
				dataType:'jsonp',//服务器返回json格式数据
				type:'post',//HTTP请求类型
				timeout:100000,//超时时间设置为10秒；
				
				success:function(data){
					var jsonObj = window.JSON.parse(data);
						var resultdata = jsonObj.data;
					if(jsonObj.resultCode=="1"){
						
					if(vclId!=null||vclId!=""){//单设备
							lng=resultdata[0].lng;
							lat=resultdata[0].lat;
							keySta=resultdata[0].keysta;
							vclNum=resultdata[0].vclnum;
							posTime=resultdata[0].postime;
							vclSpd=resultdata[0].vclspd;
							var marker=new plus.maps.Marker(new plus.maps.Point(lng,lat));
							if(keySta=1){//开机
								marker.setIcon("../../images/drawable-hdpi/arrow_green.png");
							}else{
								marker.setIcon("../../images/drawable-hdpi/arrow_red.png");
							}
							marker.setLabel(vclNum);
							var lable=vclNum+"位置:"+"/n"+"时间:"+posTime+"\n"+"车速:"+vclSpd;
							var bubble = new plus.maps.Bubble(lable);
							marker.setBubble(bubble);
							map.addOverlay(marker);
							map.setCenter(new plus.maps.Point(lng,lat));
						}else {//多设备
							for(var i=0;i<resultdata.length;i++){
								lng=resultdata[i].lng;
								lat=resultdata[i].lat;
								keySta=resultdata[i].keysta;
								vclNum=resultdata[i].vclnum;
								posTime=resultdata[i].postime;
								vclSpd=resultdata[i].vclspd;
								var marker=new plus.maps.Marker(new plus.maps.Point(lng,lat));
							if(keySta=1){//开机
								marker.setIcon("../../images/drawable-hdpi/arrow_green.png");
							}else{
								marker.setIcon("../../images/drawable-hdpi/arrow_red.png");
							}
							marker.setLabel(vclNum);
							var lable=vclNum+"\n"+"位置:"+"/n"+"时间:"+posTime+"\n"+"车速:"+vclSpd;
							var bubble = new plus.maps.Bubble(lable);
							marker.setBubble(bubble);
							map.addOverlay(marker);
							mui.toast(vclNum);
							map.centerAndZoom(new plus.maps.Point(116.3977,39.906016),4);
							}
							
							
						}
						
						
						
						
					}else{
						
					}
					
				}
				
			});
		}
		</script>
	
		<style type="text/css">
#map {
	width: 100%;
	position: fixed;
	top: 45px;
	bottom: 0px;
	line-height: 200px;
	text-align: center;
	background: #FFFFFF;
}
.ipos {
	background: no-repeat center center url();
	background-size: 50px 44px;
}		</style>
	</head>
	<body>
		<header id="header">
			
			
			<div class="nvbt ipos" onclick="userLocation();"></div>
		</header>
		<div id="map">地图加载中...</div>
	</body>
	<script type="text/javascript" src="../../js/immersed.js" ></script>
</html>